import { Profile } from '@/types';
import { Edges, Extrude } from '@react-three/drei';
import { getPlankShape } from '../utils';
import { PlankEdge } from './PlankEdge';

export function BasePlank(props: {
  profile: Profile;
  inners?: Profile[];
  width: number;
  height: number;
  thickness: number;
  edgeBanding: number[];
}) {
  const { profile, inners, width, height, thickness, edgeBanding } = props;
  const shape = getPlankShape({ profile, inners, width, height });

  return (
    <group position={[0, 0, -thickness / 2]} renderOrder={1}>
      <Extrude
        args={[
          shape,
          {
            depth: thickness,
            // extrudePath: new LineCurve3(new Vector3(0, 0, - thickness / 2), new Vector3(0, 0, thickness / 2))
          },
        ]}
      >
        <meshStandardMaterial
          args={[{ color: 'orange', transparent: true, opacity: 0.5 }]}
        />
        <Edges scale={1} color="black" />
      </Extrude>
      <PlankEdge {...{ shape, thickness, edgeBanding }} />
    </group>
  );
}
